package com.example._06springaop.bpp;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Logaspect {
    @Pointcut("execution(* com.example._06springaop.bpp.CartServiceImpl.*(..))")
    public void dotime(){}

    @Around("dotime()")
    public Object aroundMethod(ProceedingJoinPoint joinPoint) {
        Object obj=null;
        try {
            System.out.println("开始添加购物车");
            obj = joinPoint.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            System.out.println("END");
        }

        return obj;
    }
}
